<!DOCTYPE html>

<html>
<head>
<meta charset="UTF-8">
<link href="style.css" type="text/css" rel="stylesheet">
<title>PACKUSWB—Pack with Unsigned Saturation </title></head>
<body>
<h1>PACKUSWB—Pack with Unsigned Saturation</h1>
<table>
<tr>
<th>Opcode/Instruction</th>
<th>Op/En</th>
<th>64/32 bit Mode Support</th>
<th>CPUID Feature Flag</th>
<th>Description</th></tr>
<tr>
<td>
<p>0F 67 /<em>r</em><sup>1</sup></p>
<p>PACKUSWB <em>mm, mm/m64</em></p></td>
<td>RM</td>
<td>V/V</td>
<td>MMX</td>
<td>Converts 4 signed word integers from <em>mm</em> and 4 signed word integers from <em>mm/m64</em> into 8 unsigned byte integers in <em>mm</em> using unsigned saturation.</td></tr>
<tr>
<td>
<p>66 0F 67 /<em>r</em></p>
<p>PACKUSWB <em>xmm1</em>,<em> xmm2/m128</em></p></td>
<td>RM</td>
<td>V/V</td>
<td>SSE2</td>
<td>Converts 8 signed word integers from <em>xmm1 </em>and 8 signed word integers from <em>xmm2/m128 </em>into 16 unsigned byte integers in <em>xmm1</em> using unsigned saturation.</td></tr>
<tr>
<td>
<p>VEX.NDS.128.66.0F.WIG 67 /r</p>
<p>VPACKUSWB <em>xmm1, xmm2, xmm3/m128</em></p></td>
<td>RVM</td>
<td>V/V</td>
<td>AVX</td>
<td>Converts 8 signed word integers from <em>xmm2 </em>and 8 signed word integers from <em>xmm3/m128 </em>into 16 unsigned byte integers in <em>xmm1</em> using unsigned saturation.</td></tr>
<tr>
<td>
<p>VEX.NDS.256.66.0F.WIG 67 /r</p>
<p>VPACKUSWB <em>ymm1, ymm2, ymm3/m256</em></p></td>
<td>RVM</td>
<td>V/V</td>
<td>AVX2</td>
<td>Converts 16 signed word integers from <em>ymm2 </em>and 16signed word integers from <em>ymm3/m256 </em>into 32 unsigned byte integers in <em>ymm1</em> using unsigned saturation.</td></tr>
<tr>
<td>
<p>EVEX.NDS.128.66.0F.WIG 67 /r</p>
<p>VPACKUSWB <em>xmm1{k1}{z}, xmm2, xmm3/m128</em></p></td>
<td>FVM</td>
<td>V/V</td>
<td>
<p>AVX512VL</p>
<p>AVX512BW</p></td>
<td>Converts signed word integers from <em>xmm2 </em>and signed word integers from <em>xmm3/m128 </em>into unsigned byte integers in <em>xmm1</em> using unsigned saturation under writemask k1.</td></tr>
<tr>
<td>
<p>EVEX.NDS.256.66.0F.WIG 67 /r</p>
<p>VPACKUSWB <em>ymm1{k1}{z}, ymm2, ymm3/m256</em></p></td>
<td>FVM</td>
<td>V/V</td>
<td>
<p>AVX512VL</p>
<p>AVX512BW</p></td>
<td>Converts signed word integers from <em>ymm2 </em>and signed word integers from <em>ymm3/m256 </em>into unsigned byte integers in <em>ymm1</em> using unsigned saturation under writemask k1.</td></tr>
<tr>
<td>
<p>EVEX.NDS.512.66.0F.WIG 67 /r</p>
<p>VPACKUSWB <em>zmm1{k1}{z}, zmm2, zmm3/m512</em></p></td>
<td>FVM</td>
<td>V/V</td>
<td>AVX512BW</td>
<td>Converts signed word integers from <em>zmm2 </em>and signed word integers from <em>zmm3/m512 </em>into unsigned byte integers in <em>zmm1</em> using unsigned saturation under writemask k1.</td></tr></table>
<p>NOTES:</p>
<p>1. See note in Section 2.4, “AVX and SSE Instruction Exception Specification” in the <em>Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 2A</em> and Section 22.25.3, “Exception Conditions of Legacy SIMD Instructions Operating on MMX Registers” in the <em>Intel® 64 and IA-32 Architectures Software Developer’s Manual, Volume 3A</em>.</p>
<h3>Instruction Operand Encoding</h3>
<table>
<tr>
<td>Op/En</td>
<td>Operand 1</td>
<td>Operand 2</td>
<td>Operand 3</td>
<td>Operand 4</td></tr>
<tr>
<td>RM</td>
<td>ModRM:reg (r, w)</td>
<td>ModRM:r/m (r)</td>
<td>NA</td>
<td>NA</td></tr>
<tr>
<td>RVM</td>
<td>ModRM:reg (w)</td>
<td>VEX.vvvv (r)</td>
<td>ModRM:r/m (r)</td>
<td>NA</td></tr>
<tr>
<td>FVM</td>
<td>ModRM:reg (w)</td>
<td>EVEX.vvvv (r)</td>
<td>ModRM:r/m (r)</td>
<td>NA</td></tr></table>
<h2>Description</h2>
<p>Converts 4, 8, 16 or 32 signed word integers from the destination operand (first operand) and 4, 8, 16 or 32 signed word integers from the source operand (second operand) into 8, 16, 32 or 64 unsigned byte integers and stores the result in the destination operand. (See Figure 4-6 for an example of the packing operation.) If a signed word integer value is beyond the range of an unsigned byte integer (that is, greater than FFH or less than 00H), the satu-rated unsigned byte integer value of FFH or 00H, respectively, is stored in the destination.</p>
<p>EVEX.512 encoded version: The first source operand is a ZMM register. The second source operand is a ZMM register or a 512-bit memory location. The destination operand is a ZMM register.</p>
<p>VEX.256 and EVEX.256 encoded versions: The first source operand is a YMM register. The second source operand is a YMM register or a 256-bit memory location. The destination operand is a YMM register. The upper bits (MAX_VL-1:256) of the corresponding ZMM register destination are zeroed.</p>
<p>VEX.128 and EVEX.128 encoded versions: The first source operand is an XMM register. The second source operand is an XMM register or 128-bit memory location. The destination operand is an XMM register. The upper bits (MAX_VL-1:128) of the corresponding register destination are zeroed.</p>
<p>128-bit Legacy SSE version: The first source operand is an XMM register. The second operand can be an XMM register or an 128-bit memory location. The destination is not distinct from the first source XMM register and the upper bits (MAX_VL-1:128) of the corresponding register destination are unmodified.</p>
<h2>Operation</h2>
<p><strong>PACKUSWB (with 64-bit operands)</strong></p>
<pre>    DEST[7:0] ← SaturateSignedWordToUnsignedByte DEST[15:0];
    DEST[15:8] ← SaturateSignedWordToUnsignedByte DEST[31:16];
    DEST[23:16] ← SaturateSignedWordToUnsignedByte DEST[47:32];
    DEST[31:24] ← SaturateSignedWordToUnsignedByte DEST[63:48];
    DEST[39:32] ← SaturateSignedWordToUnsignedByte SRC[15:0];
    DEST[47:40] ← SaturateSignedWordToUnsignedByte SRC[31:16];
    DEST[55:48] ← SaturateSignedWordToUnsignedByte SRC[47:32];
    DEST[63:56] ← SaturateSignedWordToUnsignedByte SRC[63:48];</pre>
<p><strong>PACKUSWB (Legacy SSE instruction)</strong></p>
<pre>    DEST[7:0](cid:197)SaturateSignedWordToUnsignedByte (DEST[15:0]);
    DEST[15:8] (cid:197)SaturateSignedWordToUnsignedByte (DEST[31:16]);
    DEST[23:16] (cid:197)SaturateSignedWordToUnsignedByte (DEST[47:32]);
    DEST[31:24] (cid:197) SaturateSignedWordToUnsignedByte (DEST[63:48]);
    DEST[39:32] (cid:197) SaturateSignedWordToUnsignedByte (DEST[79:64]);
    DEST[47:40] (cid:197) SaturateSignedWordToUnsignedByte (DEST[95:80]);
    DEST[55:48] (cid:197) SaturateSignedWordToUnsignedByte (DEST[111:96]);
    DEST[63:56] (cid:197) SaturateSignedWordToUnsignedByte (DEST[127:112]);
    DEST[71:64] (cid:197) SaturateSignedWordToUnsignedByte (SRC[15:0]);
    DEST[79:72] (cid:197) SaturateSignedWordToUnsignedByte (SRC[31:16]);
    DEST[87:80] (cid:197) SaturateSignedWordToUnsignedByte (SRC[47:32]);
    DEST[95:88] (cid:197) SaturateSignedWordToUnsignedByte (SRC[63:48]);
    DEST[103:96] (cid:197) SaturateSignedWordToUnsignedByte (SRC[79:64]);
    DEST[111:104] (cid:197) SaturateSignedWordToUnsignedByte (SRC[95:80]);
    DEST[119:112] (cid:197) SaturateSignedWordToUnsignedByte (SRC[111:96]);
    DEST[127:120] (cid:197) SaturateSignedWordToUnsignedByte (SRC[127:112]);</pre>
<p><strong>PACKUSWB (VEX.128 encoded version)</strong></p>
<pre>    DEST[7:0](cid:197) SaturateSignedWordToUnsignedByte (SRC1[15:0]);
    DEST[15:8] (cid:197)SaturateSignedWordToUnsignedByte (SRC1[31:16]);
    DEST[23:16] (cid:197)SaturateSignedWordToUnsignedByte (SRC1[47:32]);
    DEST[31:24] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[63:48]);
    DEST[39:32] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[79:64]);
    DEST[47:40] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[95:80]);
    DEST[55:48] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[111:96]);
    DEST[63:56] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[127:112]);
    DEST[71:64] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[15:0]);
    DEST[79:72] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[31:16]);
    DEST[87:80] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[47:32]);
    DEST[95:88] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[63:48]);
    DEST[103:96] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[79:64]);
    DEST[111:104] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[95:80]);
    DEST[119:112] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[111:96]);
    DEST[127:120] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[127:112]);
    DEST[VLMAX-1:128] (cid:197) 0;</pre>
<p><strong>VPACKUSWB (VEX.256 encoded version)</strong></p>
<pre>    DEST[7:0](cid:197) SaturateSignedWordToUnsignedByte (SRC1[15:0]);
    DEST[15:8] (cid:197)SaturateSignedWordToUnsignedByte (SRC1[31:16]);
    DEST[23:16] (cid:197)SaturateSignedWordToUnsignedByte (SRC1[47:32]);
    DEST[31:24] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[63:48]);
    DEST[39:32] (cid:197)SaturateSignedWordToUnsignedByte (SRC1[79:64]);
    DEST[47:40] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[95:80]);
    DEST[55:48] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[111:96]);
    DEST[63:56] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[127:112]);
    DEST[71:64] (cid:197)SaturateSignedWordToUnsignedByte (SRC2[15:0]);
    DEST[79:72] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[31:16]);
    DEST[87:80] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[47:32]);
    DEST[95:88] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[63:48]);
    DEST[103:96] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[79:64]);
    DEST[111:104] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[95:80]);
    DEST[119:112] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[111:96]);
    DEST[127:120] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[127:112]);
    DEST[135:128](cid:197) SaturateSignedWordToUnsignedByte (SRC1[143:128]);
    DEST[143:136] (cid:197)SaturateSignedWordToUnsignedByte (SRC1[159:144]);
    DEST[151:144] (cid:197)SaturateSignedWordToUnsignedByte (SRC1[175:160]);
    DEST[159:152] (cid:197)SaturateSignedWordToUnsignedByte (SRC1[191:176]);
    DEST[167:160] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[207:192]);
    DEST[175:168] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[223:208]);
    DEST[183:176] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[239:224]);
    DEST[191:184] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[255:240]);
    DEST[199:192] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[143:128]);
    DEST[207:200] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[159:144]);
    DEST[215:208] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[175:160]);
    DEST[223:216] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[191:176]);
    DEST[231:224] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[207:192]);
    DEST[239:232] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[223:208]);
    DEST[247:240] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[239:224]);
    DEST[255:248] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[255:240]);</pre>
<p><strong>VPACKUSWB (EVEX encoded versions)</strong></p>
<pre>(KL, VL) = (16, 128), (32, 256), (64, 512)
TMP_DEST[7:0] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[15:0]);
TMP_DEST[15:8] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[31:16]);
TMP_DEST[23:16] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[47:32]);
TMP_DEST[31:24] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[63:48]);
TMP_DEST[39:32] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[79:64]);
TMP_DEST[47:40] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[95:80]);
TMP_DEST[55:48] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[111:96]);
TMP_DEST[63:56] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[127:112]);
TMP_DEST[71:64] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[15:0]);
TMP_DEST[79:72] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[31:16]);
TMP_DEST[87:80] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[47:32]);
TMP_DEST[95:88] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[63:48]);
TMP_DEST[103:96] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[79:64]);
TMP_DEST[111:104] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[95:80]);
TMP_DEST[119:112] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[111:96]);
TMP_DEST[127:120] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[127:112]);
IF VL &gt;= 256
    TMP_DEST[135:128](cid:197) SaturateSignedWordToUnsignedByte (SRC1[143:128]);
    TMP_DEST[143:136] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[159:144]);
    TMP_DEST[151:144] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[175:160]);
    TMP_DEST[159:152] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[191:176]);
    TMP_DEST[167:160] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[207:192]);
    TMP_DEST[175:168] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[223:208]);
    TMP_DEST[183:176] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[239:224]);
    TMP_DEST[191:184] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[255:240]);
    TMP_DEST[199:192] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[143:128]);
    TMP_DEST[207:200] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[159:144]);
    TMP_DEST[215:208] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[175:160]);
    TMP_DEST[223:216] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[191:176]);
    TMP_DEST[231:224] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[207:192]);
    TMP_DEST[239:232] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[223:208]);
    TMP_DEST[247:240] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[239:224]);
    TMP_DEST[255:248] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[255:240]);
FI;
IF VL &gt;= 512
    TMP_DEST[263:256] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[271:256]);
    TMP_DEST[271:264] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[287:272]);
    TMP_DEST[279:272] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[303:288]);
    TMP_DEST[287:280] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[319:304]);
    TMP_DEST[295:288] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[335:320]);
    TMP_DEST[303:296] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[351:336]);
    TMP_DEST[311:304] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[367:352]);
    TMP_DEST[319:312] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[383:368]);
    TMP_DEST[327:320] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[271:256]);
    TMP_DEST[335:328] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[287:272]);
    TMP_DEST[343:336] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[303:288]);
    TMP_DEST[351:344] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[319:304]);
    TMP_DEST[359:352] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[335:320]);
    TMP_DEST[367:360] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[351:336]);
    TMP_DEST[375:368] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[367:352]);
    TMP_DEST[383:376] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[383:368]);
    TMP_DEST[391:384] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[399:384]);
    TMP_DEST[399:392] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[415:400]);
    TMP_DEST[407:400] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[431:416]);
    TMP_DEST[415:408] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[447:432]);
    TMP_DEST[423:416] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[463:448]);
    TMP_DEST[431:424] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[479:464]);
    TMP_DEST[439:432] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[495:480]);
    TMP_DEST[447:440] (cid:197) SaturateSignedWordToUnsignedByte (SRC1[511:496]);
    TMP_DEST[455:448] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[399:384]);
    TMP_DEST[463:456] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[415:400]);
    TMP_DEST[471:464] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[431:416]);
    TMP_DEST[479:472] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[447:432]);
    TMP_DEST[487:480] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[463:448]);
    TMP_DEST[495:488] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[479:464]);
    TMP_DEST[503:496] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[495:480]);
    TMP_DEST[511:504] (cid:197) SaturateSignedWordToUnsignedByte (SRC2[511:496]);
FI;
FOR j (cid:197) 0 TO KL-1
    i (cid:197) j * 8
    IF k1[j] OR *no writemask*
         THEN
              DEST[i+7:i] (cid:197) TMP_DEST[i+7:i]
         ELSE
              IF *merging-masking*
                                                         ; merging-masking
                    THEN *DEST[i+7:i] remains unchanged*
                    ELSE *zeroing-masking*
                                                               ; zeroing-masking
                         DEST[i+7:i] (cid:197) 0
              FI
    FI;
ENDFOR;
DEST[MAX_VL-1:VL] (cid:197) 0</pre>
<p><strong>Intel C/C++ Compiler Intrinsic Equivalents</strong></p>
<pre>VPACKUSWB__m512i _mm512_packus_epi16(__m512i m1, __m512i m2);
VPACKUSWB__m512i _mm512_mask_packus_epi16(__m512i s, __mmask64 k, __m512i m1, __m512i m2);
VPACKUSWB__m512i _mm512_maskz_packus_epi16(__mmask64 k, __m512i m1, __m512i m2);
VPACKUSWB__m256i _mm256_mask_packus_epi16(__m256i s, __mmask32 k, __m256i m1, __m256i m2);
VPACKUSWB__m256i _mm256_maskz_packus_epi16(__mmask32 k, __m256i m1, __m256i m2);
VPACKUSWB__m128i _mm_mask_packus_epi16(__m128i s, __mmask16 k, __m128i m1, __m128i m2);
VPACKUSWB__m128i _mm_maskz_packus_epi16(__mmask16 k, __m128i m1, __m128i m2);
PACKUSWB:
                  __m64 _mm_packs_pu16(__m64 m1, __m64 m2)
(V)PACKUSWB:  __m128i _mm_packus_epi16(__m128i m1, __m128i m2)
VPACKUSWB:
                    __m256i _mm256_packus_epi16(__m256i m1, __m256i m2);</pre>
<h2>Flags Affected</h2>
<p>None</p>
<h2>SIMD Floating-Point Exceptions</h2>
<p>None</p>
<h2>Other Exceptions</h2>
<p>Non-EVEX-encoded instruction, see Exceptions Type 4.</p>
<p>EVEX-encoded instruction, see Exceptions Type E4NF.nb.</p></body></html>